package com.Arsanesia.TempleRush.Controllers.Listeners.ButtonListeners;

import com.Arsanesia.TempleRush.Controllers.World;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;

public class GamePauseListener extends ClickListener{
	private World world;
	private Image pausehome;
	private ImageButton pausevibrate, pausesound;
	private float buttonWidth, buttonHeight;
	public GamePauseListener(){
		super();
	}
	public GamePauseListener(World _world, Image pausehomebutton, ImageButton pausevibratebutton, 
								ImageButton pausesoundbutton, float buttonwidth, float buttonheight){
		this.world= _world;
		pausehome = pausehomebutton;
		//set up vibration button
		pausevibrate = pausevibratebutton;
		//set up sound button
		pausesound = pausesoundbutton;
		this.buttonWidth = buttonwidth;
		this.buttonHeight = buttonheight;
	}
	@Override
	public void clicked(InputEvent event, float x, float y){
		super.clicked(event,x,y);
		//toggle the pause world or not
		world.togglePaused();
		if(world.isWorldReady()){
			pausehome.addAction(Actions.moveTo(0, 0, 0.1f));
			pausevibrate.addAction(Actions.moveTo(0, 0, 0.1f));
			pausesound.addAction(Actions.moveTo(0, 0, 0.1f));
		}
		else{
			pausehome.addAction(Actions.moveTo(buttonWidth+pausehome.getWidth(),0, 0.5f));
			pausesound.addAction(Actions.moveTo(buttonWidth+pausehome.getWidth()-10,buttonHeight+pausevibrate.getHeight()-10, 0.5f));
			pausevibrate.addAction(Actions.moveTo(0,buttonHeight+pausevibrate.getHeight(), 0.5f));
			
			
		}
	}
}
